home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / il / ilCallback.z / ilCallback
Encoding:
Text File  |  2002-10-03  |  7.3 KB  |  199 lines

  1.  
  2.  
  3.  
  4. iiiillllCCCCaaaallllllllbbbbaaaacccckkkk((((3333))))      IIIImmmmaaaaggggeeeeVVVViiiissssiiiioooonnnn LLLLiiiibbbbrrrraaaarrrryyyy CCCC++++++++ RRRReeeeffffeeeerrrreeeennnncccceeee MMMMaaaannnnuuuuaaaallll      iiiillllCCCCaaaallllllllbbbbaaaacccckkkk((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      iiiillllCCCCaaaallllllllbbbbaaaacccckkkk - generic call back mechanism
  10.  
  11. IIIINNNNHHHHEEEERRRRIIIITTTTSSSS FFFFRRRROOOOMMMM
  12.      ilCacheBase
  13.  
  14. HHHHEEEEAAAADDDDEEEERRRR FFFFIIIILLLLEEEE
  15.      #include <il/ilCallback.h>
  16.  
  17. CCCCLLLLAAAASSSSSSSS DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  18.      This class provide a generic call back mechanism.  There are two derived
  19.      class templates, ilFunctionCallback and ilMethodCallback, that provide
  20.      either normal function callbacks or callbacks to a method on some object,
  21.      repectively.
  22.  
  23.      The ilFunctionCallback template is used to create a callback to a
  24.      function that takes an argument, _u_s_e_r_A_r_g, that is supplied when the
  25.      callback is created and a second argument, _c_a_l_l_e_r_A_r_g that is passed from
  26.      the callsite of the callback (i.e. when ddddooooiiiitttt() is called). A callback
  27.      function, 'func', thus has the prototype:
  28.  
  29.           ilStatus func(UserArgType userArg, CallerArgType callerArg);
  30.  
  31.  
  32.      The ilMethodCallback template is used to create a callback to a method on
  33.      an object of type UserClass that takes an argument, _u_s_e_r_A_r_g, that is
  34.      supplied when the callback is created and a second argument, _c_a_l_l_e_r_A_r_g,
  35.      that is passed from the callsite of the callback (i.e. when ddddooooiiiitttt() is
  36.      called). Thus a callback 'method' would have the prototype:
  37.  
  38.           ilStatus UserClass::method(UserArgType userArg, CallerArgType callerArg);
  39.  
  40.  
  41. CCCCLLLLAAAASSSSSSSS MMMMEEEEMMMMBBBBEEEERRRR FFFFUUUUNNNNCCCCTTTTIIIIOOOONNNN SSSSUUUUMMMMMMMMAAAARRRRYYYY
  42.      CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  43.  
  44.           ilFunctionCallback(ilStatus (*func)(UserArgType userArg,
  45.                                               CallerArgType callerArg),
  46.                              UserArgType userArg)
  47.           ilMethodCallback(UserClass* object,
  48.                            ilStatus (UserClass::*method)(UserArgType userArg,
  49.                                                          CallerArgType callerArg),
  50.                            UserArgType userArg)
  51.           ilNullCallback()
  52.  
  53.      CCCCaaaallllllllbbbbaaaacccckkkk aaaaccccttttiiiioooonnnn
  54.  
  55.           virtual ilStatus doit(void* callerArg)
  56.  
  57.      SSSSeeeetttt mmmmeeeetttthhhhooooddddssss
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. iiiillllCCCCaaaallllllllbbbbaaaacccckkkk((((3333))))      IIIImmmmaaaaggggeeeeVVVViiiissssiiiioooonnnn LLLLiiiibbbbrrrraaaarrrryyyy CCCC++++++++ RRRReeeeffffeeeerrrreeeennnncccceeee MMMMaaaannnnuuuuaaaallll      iiiillllCCCCaaaallllllllbbbbaaaacccckkkk((((3333))))
  71.  
  72.  
  73.  
  74.           void setUserArg(UserArgType userArg)
  75.  
  76.  
  77. FFFFUUUUNNNNCCCCTTTTIIIIOOOONNNN DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNNSSSS
  78.      iiiillllFFFFuuuunnnnccccttttiiiioooonnnnCCCCaaaallllllllbbbbaaaacccckkkk(((())))
  79.  
  80.           ilFunctionCallback(ilStatus (*func)(UserArgType userArg,
  81.                                               CallerArgType callerArg),
  82.                              UserArgType userArg)
  83.  
  84.  
  85.           This constructor creates a callback to function, _f_u_n_c, with user
  86.           argument, _u_s_e_r_A_r_g.
  87.  
  88.           To define a callback to a simple function rrrreeeeaaaaddddyyyy() you might do
  89.           something like:
  90.  
  91.               ...
  92.               ilStatus ready(UserType*, CallerType*) { ... }
  93.               ...
  94.               typedef ilFunctionCallback<UserType*,CallerType*> UserCallback;
  95.  
  96.               Bar bar;
  97.               UserType userArg;
  98.               UserCallback doneCb(ready, &userArg);
  99.  
  100.  
  101.           and to invoke it from the callsite you would write something like:
  102.  
  103.               CallerType callerArg;
  104.               donecb.doit(&callerArg);
  105.  
  106.  
  107.      iiiillllMMMMeeeetttthhhhooooddddCCCCaaaallllllllbbbbaaaacccckkkk(((())))
  108.  
  109.           ilMethodCallback(UserClass* object,
  110.                            ilStatus (UserClass::*method)(UserArgType userArg,
  111.                                                          CallerArgType callerArg),
  112.                            UserArgType userArg)
  113.  
  114.  
  115.           This constructor creates a callback to _U_s_e_r_C_l_a_s_s::_m_e_t_h_o_d, with user
  116.           argument, _u_s_e_r_A_r_g.
  117.  
  118.           To define a callback to a member function BBBBaaaarrrr::::::::ddddoooonnnneeee() you might do
  119.           something like:
  120.  
  121.               ...
  122.               ilStatus Bar::done(UserType*, CallerType*) { ... }
  123.               ...
  124.               typedef ilMethodCallback<Bar,UserType*,CallerType*> UserCallback;
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. iiiillllCCCCaaaallllllllbbbbaaaacccckkkk((((3333))))      IIIImmmmaaaaggggeeeeVVVViiiissssiiiioooonnnn LLLLiiiibbbbrrrraaaarrrryyyy CCCC++++++++ RRRReeeeffffeeeerrrreeeennnncccceeee MMMMaaaannnnuuuuaaaallll      iiiillllCCCCaaaallllllllbbbbaaaacccckkkk((((3333))))
  137.  
  138.  
  139.  
  140.               Bar bar;
  141.               UserType userArg;
  142.               UserCallback doneCb(&bar, Bar::done, &userArg);
  143.  
  144.  
  145.           and to invoke it from the callsite you would write something like:
  146.  
  147.               CallerType callerArg;
  148.               donecb.doit(&callerArg);
  149.  
  150.  
  151.      iiiillllNNNNuuuullllllllCCCCaaaallllllllbbbbaaaacccckkkk(((())))
  152.  
  153.           ilNullCallback()
  154.  
  155.  
  156.           This constructor creates a callback that does nothing.
  157.  
  158.      ddddooooiiiitttt(((())))
  159.  
  160.           virtual ilStatus doit(void* callerArg)
  161.  
  162.  
  163.           This method is called to trigger the callback; the semantics of this
  164.           are defined by one of two derived classes: either ilFunctionCallback
  165.           or ilMethodCallback.  The returned value is the value returned from
  166.           the callback function or method.
  167.  
  168. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  169.      ilCallbackList(3)
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.